package euler.p001_050;

import euler.MainEuler;
import euler.helper.NaturalHelper;

public class Euler036 extends MainEuler {

    /*
        The decimal number, 585 = 1001001001(2) (binary),
        is palindromic in both bases.

        Find the sum of all numbers, less than one million,
        which are palindromic in base 10 and base 2.

        (Please note that the palindromic number,
        in either base, may not include leading zeros.)

     */

    public String resolve() {

        int limite = 1000000;
        int suma = 0;

        for (int i = 0; i < limite; i++) {
            if (NaturalHelper.isPalindromo(i,10) && NaturalHelper.isPalindromo(i,2)) {
                suma+=i;
            }
        }

        return String.valueOf(suma);
    }

}
